const Router = require("koa-router");
const router = new Router({ prefix: "/user" });
const { authorverify } = require("../middleware/auth.middleware");

const {
  getallcollectessayid,
  register,
  login,
  getallusers,
  accomplish,
  updateuser,
  getoneuser,
  giteelogin,
  bygitee,
  mangelogin,
  deleteone,
} = require("../controller/user.controller");

//注册
router.post("/register", register);
//登录
router.post("/login", login);
//查询当前用户收藏的所有文章的id，点赞的所有评论的id，点赞的所有留言的id
router.get("/getallcollectessayid/:id", getallcollectessayid);
//获取所有用户信息
router.get("/getallusers", getallusers);
//用户个人成就
router.get("/accomplish/:id", accomplish);
//修改用户信息
router.patch("/updateuser/:id", authorverify, updateuser);
//根据id重新获取用户信息
router.get("/getoneuser/:id", getoneuser);
//三方登录
router.get("/giteelogin", giteelogin);
//根据giteeid获取用户信息
router.get("/bygitee/:id", bygitee);

//管理员登录
router.post("/mangelogin", mangelogin);
//获取所有用户信息（包含搜索）
router.get("/getallusersman", authorverify, getallusers);
//删除用户
router.delete("/deleteone/:id", authorverify, deleteone);

module.exports = router;
